﻿{smcl}
{* 12July2017}{...}
{hi:help sum2docx}
{hline}

{title:Title}

{phang}
{bf:sum2docx} {hline 2} Report summary statistics to formatted table in DOCX file.


{marker syntax}{...}
{title:Syntax}

{p 8 17 2}
{cmdab:sum2docx} {it:varlist} [{it:if}] [{it:in}] {it:using filename} {cmd:,} [{it:options}]

where varlist is a list of non-string variables , or _all.  The * and ? wildcards are allowed in varlist


{marker description}{...}
{title:Description}

{pstd}
{cmd:sum2docx} can report all the statistics which can be reported by command {cmd:summarize} in detail model. You can specify those statistics as options. Users can also append 
the output from {cmd:sum2docx} to other docx documents, which is more likely to be generated by {cmd:putdocx}, {cmd:reg2docx} and ect, either using the {it:append} option or the 
command can be as following: {p_end}

{phang}
{stata `"putdocx append d:/mytable0.docx d:/mytable1.docx d:/mytable2.docx, saving(d:/mytable.docx,replace)"'}
{p_end}


{marker options}{...}
{title:Options for wordconvert}

{phang}
{opt replace} permits to overwrite an existing file. {p_end}

{phang}
{opt append} permits to append the output to an existing file. {p_end}

{phang}
{opt title(string)} specify the title of the table. {p_end}

{phang}
{opt obs} output the number of the observations. {p_end}

{phang}
{opt mean}{opt [}{opt (fmt)}{opt ]} output mean and specify the format. {p_end}

{phang}
{opt var}{opt [}{opt (fmt)}{opt ]} output variance and specify the format. {p_end}

{phang}
{opt sd}{opt [}{opt (fmt)}{opt ]} output standard deviation and specify the format. {p_end}

{phang}
{opt skewness}{opt [}{opt (fmt)}{opt ]} output skewness and specify the format. {p_end}

{phang}
{opt kurtosis}{opt [}{opt (fmt)}{opt ]} output kurtosis and specify the format. {p_end}

{phang}
{opt sum}{opt [}{opt (fmt)}{opt ]} output sum and specify the format. {p_end}

{phang}
{opt min}{opt [}{opt (fmt)}{opt ]} output min and specify the format. {p_end}

{phang}
{opt median}{opt [}{opt (fmt)}{opt ]} output median and specify the format. {p_end}

{phang}
{opt max}{opt [}{opt (fmt)}{opt ]} output max and specify the format. {p_end}

{phang}
{opt p1}{opt [}{opt (fmt)}{opt ]} output 1st percentile and specify the format. {p_end}

{phang}
{opt p5}{opt [}{opt (fmt)}{opt ]} output 5th percentile and specify the format. {p_end}

{phang}
{opt p10}{opt [}{opt (fmt)}{opt ]} output 10th percentile and specify the format. {p_end}

{phang}
{opt p25}{opt [}{opt (fmt)}{opt ]} output 25th percentile and specify the format. {p_end}

{phang}
{opt p75}{opt [}{opt (fmt)}{opt ]} output 75th percentile and specify the format. {p_end}

{phang}
{opt p90}{opt [}{opt (fmt)}{opt ]} output 90th percentile and specify the format. {p_end}

{phang}
{opt p95}{opt [}{opt (fmt)}{opt ]} output 95th percentile and specify the format. {p_end}

{phang}
{opt p99}{opt [}{opt (fmt)}{opt ]} output 99th percentile and specify the format. {p_end}


{marker example}{...}
{title:Example}

{pstd}

{phang}
{stata `"sysuse auto, clear"'}
{p_end}

{pstd}
Report summary statistics for variable mpg weight length rep78 and foreign

{phang}
{stata `"sum2docx mpg weight length rep78 foreign using d:/temp1.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g)"'}
{p_end}

{pstd}
Add table tile

{phang}
{stata `"sum2docx mpg weight length rep78 foreign using d:/temp2.docx, replace obs mean sd min median max title("this is the summary statistics")"'}
{p_end}

{pstd}
Add format for summary statistics

{phang}
{stata `"sum2docx mpg weight length rep78 foreign using d:/temp3.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("this is the summary statistics")"'}
{p_end}

{pstd}
Use wild card

{phang}
{stata `"sum2docx *n* m?g using d:/temp4.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("Table 1: this is the summary statistics")"'}
{p_end}

{pstd}
Use all variables

{phang}
{stata `"drop make"'}
{p_end}

{phang}
{stata `"sum2docx _all using d:/temp5.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("Table 1: this is the summary statistics")"'}
{p_end}

{pstd}
Append all files together

{phang}
{stata `"putdocx append d:/temp1.docx d:/temp2.docx d:/temp3.docx d:/temp4.docx d:/temp5.docx, saving(d:/mytable.docx,replace)"'}
{p_end}

{pstd}
We can also use the option append to append the output to an existing file

{phang}
{stata `"sum2docx mpg weight length rep78 foreign using d:/mytable.docx, append obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("this is the summary statistics")"'}
{p_end}


{title:Author}

{pstd}Chuntao LI{p_end}
{pstd}China Stata Club(爬虫俱乐部){p_end}
{pstd}Wuhan, China{p_end}
{pstd}chtl@zuel.edu.cn{p_end}

{pstd}Yuan XUE{p_end}
{pstd}China Stata Club(爬虫俱乐部){p_end}
{pstd}Wuhan, China{p_end}
{pstd}xueyuan19920310@163.com{p_end}


